
gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************

use "${Inputs}\NY_fs_subgroups.dta", clear

compress
keep if spec=="First Stage, With Controls"
drop spec 

gen string_beta = string(beta, "%10.3fc")
gen string_se = "(" + string(se, "%10.3fc") +")"
gen string_obs = string(N, "%12.0fc")
keep group string*

reshape long string_ , i(group) j(item) string
replace group = lower(group)

levelsof group, local(groups)
levelsof item, local(items)

foreach gg in `groups' {
	if "`gg'"=="`gg'" local id1 = "`gg'"
	
	foreach ii in `items' {
		if "`ii'"=="`ii'" local id2 = "`ii'"
		
		levelsof string if group=="`gg'" & item=="`ii'", clean local(`gg'_`ii')
	}
}

texdoc init "${Outputs}/Supplementary data_Table_G12.tex", replace force 
tex {\footnotesize \begin{tabular}{l c c c c} \hline \toprule 
tex Sample & Coefficient & Standard Error & P-Value & Observations \\ 
tex \hline
tex Male & `notfemale_beta' & `notfemale_se' & < 0.001 & `notfemale_obs' \\
tex Female & `female_beta' & `female_se' & < 0.001 & `female_obs' \\
tex Black & `black_beta' & `black_se' & < 0.001 & `black_obs' \\
tex Not Black & `notblack_beta' & `notblack_se' & < 0.001 & `notblack_obs' \\
tex First Case & `firstcase_beta' & `firstcase_se' & < 0.001 & `firstcase_obs' \\
tex Not First Case & `notfirstcase_beta' & `notfirstcase_se' & < 0.001 & `notfirstcase_obs' \\

tex \bottomrule \\

tex	\end{tabular} }
texdoc close	
	